//
//  UIView+MM.h
/*
 杜蒙 iOS开发
 annidy
*/

#define m_weakify(object) \
    autoreleasepool {}    \
    __weak typeof(object) weak##object = object
#define m_strongify(object) \
    autoreleasepool {}      \
    __strong typeof(weak##object) object = weak##object

#import <UIKit/UIKit.h>
@class MMLayout1;
@interface                                       UIView (Layout)
@property(strong, nonatomic, readonly) MMLayout1 *mm_selfLayout;
- (void)setMm_x1:(CGFloat)mm_x1;            ///<< set frame.x
- (CGFloat)mm_x1;                          ///<< get frame.x
- (void)setMm_y1:(CGFloat)mm_y1;            ///<< set frame.y
- (CGFloat)mm_y1;                          ///<< get frame.y
- (void)setMm_w1:(CGFloat)mm_w1;            ///<< set frame.bounds.size.width
- (CGFloat)mm_w1;                          ///<< get frame.bounds.size.width
- (void)setMm_h1:(CGFloat)mm_h1;            ///<< set frame.bounds.size.height
- (CGFloat)mm_h1;                          ///<< get frame.bounds.size.height
- (void)setMm_center1:(CGPoint)mm_center1;  ///<< set frame.origin
- (CGPoint)mm_center1;                     ///<< get frame origin
- (CGFloat)mm_centerX1;                    ///<< get self.center.x
- (CGFloat)mm_centerY1;                    ///<< get self.center.y
- (CGFloat)mm_maxY1;                       ///<< get CGRectGetMaxY
- (CGFloat)mm_minY1;                       ///<< get CGRectGetMinY
- (CGFloat)mm_maxX1;                       ///<< get CGRectGetMaxX
- (CGFloat)mm_minX1;                       ///<< get CGRectGetMinX
- (CGFloat)mm_halfW1;                      ///<< get self.width / 2
- (CGFloat)mm_halfH1;                      ///<< get self.height / 2
- (CGFloat)mm_halfX1;                      ///<< get self.x / 2
- (CGFloat)mm_halfY1;                      ///<< get self.y / 2
- (CGFloat)mm_halfCenterX1;                ///<< get self.centerX / 2
- (CGFloat)mm_halfCenterY1;                ///<< get self.centerY / 2
- (void)setMm_size1:(CGSize)mm_size1;
- (CGSize)mm_size1;  ///<< get self.bounds.size

// iPhoneX adapt

@property(readonly) CGFloat mm_safeAreaBottomGap1;
@property(readonly) CGFloat mm_safeAreaTopGap1;
@property(readonly) CGFloat mm_safeAreaLeftGap1;
@property(readonly) CGFloat mm_safeAreaRightGap1;

/*
   示例链接编程
   self.m_width(100).m_height(100).m_left(10).m_top(10)
*/
- (UIView * (^)(CGFloat top))m_top1;             ///< set frame y
- (UIView * (^)(CGFloat right))m_flexToTop1;     ///< set frame y by change height
- (UIView * (^)(CGFloat bottom))m_bottom1;       ///< set frame y
- (UIView * (^)(CGFloat right))m_flexToBottom1;  ///< set frame y by change height
- (UIView * (^)(CGFloat left))m_left1;           ///< set frame x
- (UIView * (^)(CGFloat right))m_flexToLeft1;    ///< set frame right by chang width
- (UIView * (^)(CGFloat right))m_right1;         ///< set frame x
- (UIView * (^)(CGFloat right))m_flexToRight1;   ///< set frame right by chang width
- (UIView * (^)(CGFloat width))m_width1;         ///< set frame width
- (UIView * (^)(CGFloat height))m_height1;       ///< set frame height
- (UIView * (^)(CGSize size))m_size1;            ///< set frame size
- (UIView * (^)(CGPoint center))m__center1;      ///< set frame center point
- (UIView * (^)(void))m_center1;                 ///< set frame center  前提是有w h 调用次方法居中父类
- (UIView * (^)(void))m_centerY1;                ///< set frame Ycenter  前提是有h调用次方法居中父类
- (UIView * (^)(void))m_centerX1;                ///< set frame Xcenter  前提是有w调用次方法居中父类

/*
 相对父View
 */
- (UIView * (^)(void))m_fill1;  ///< 填充

- (UIView * (^)(UIView *obj))m_equalToFrame1;   ///  equalTo frame
- (UIView * (^)(UIView *obj))m_equalToTop1;     ///  equalTo top
- (UIView * (^)(UIView *obj))m_equalToBottom1;  ///  equalTo Bottom
- (UIView * (^)(UIView *obj))m_equalToLeft1;    ///  equalTo left
- (UIView * (^)(UIView *obj))m_equalToRight1;   ///  equalTo right
- (UIView * (^)(UIView *obj))m_equalToWidth1;   ///  equalTo width
- (UIView * (^)(UIView *obj))m_equalToHeight1;  ///  equalTo height
- (UIView * (^)(UIView *obj))m_equalToSize1;    ///  equalTo size
- (UIView * (^)(UIView *obj))m_equalToCenter1;  ///  equalTo center

- (UIView * (^)(void))m_sizeToFit1;  ///  call sizeToFit

- (NSData *)mm_createPDF1;  /// create self PDF

- (UIViewController *)viewController1;  // self Responder UIViewControler

@end
